//
//  ScanResultViewController.m
//  PropertyManager
//
//  Created by TNG on 2018/8/4.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "ScanResultViewController.h"

@interface ScanResultViewController ()

@property (strong, nonatomic) UIView * bgView;
@property (strong, nonatomic) UILabel * titleLabel;
@property (strong, nonatomic) UILabel * numLabel;
@property (strong, nonatomic) UILabel * nameLabel;
@property (strong, nonatomic) UIButton * btn;
@property (strong, nonatomic) UILabel * timeLabel;

@end

@implementation ScanResultViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = SFM242;
    
    [self.view addSubview:self.bgView];
    [self.bgView addSubview:self.titleLabel];
    [self.bgView addSubview:self.numLabel];
    [self.bgView addSubview:self.nameLabel];
    [self.bgView addSubview:self.btn];
    [self.bgView addSubview:self.timeLabel];
    
    self.titleLabel.text = @"A栋6楼电梯口";
    self.numLabel.text = @"巡检区域编号：GH1298567890";
    self.nameLabel.text = @"张三｜13456789012";
    self.timeLabel.text = @"检查时间：2017-03-12 9:00";
}

-(UIView *)bgView
{
    if (_bgView == nil) {
        _bgView = [[UIView alloc] initWithFrame:CGRectMake(15, kStatusAndNavBarH + 20, WIDTH - 30, HEIGHT - kStatusAndNavBarH - kHomeLineH - 20 - 77)];
        _bgView.backgroundColor = SFMWhiteColor;
        _bgView.layer.cornerRadius = 4;
        _bgView.clipsToBounds = YES;
    }
    return _bgView;
}

-(UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 75, WIDTH - 30, 27)];
        _titleLabel.font = font(24);
        _titleLabel.textColor = SFM51;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}

-(UILabel *)numLabel
{
    if (_numLabel == nil) {
        _numLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 115, WIDTH - 30, 16)];
        _numLabel.font = font(12);
        _numLabel.textColor = SFM153;
        _numLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _numLabel;
}


-(UILabel *)nameLabel
{
    if (_nameLabel == nil) {
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 132, WIDTH - 30, 17)];
        _nameLabel.font = font(12);
        _nameLabel.textColor = SFM153;
        _nameLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLabel;
}

-(UIButton *)btn
{
    if (_btn == nil) {
        _btn = [[UIButton alloc] initWithFrame:CGRectMake(WIDTH/2 - 58, 240, 86, 86)];
        [_btn setTitle:@"巡检打卡" forState:UIControlStateNormal];
        _btn.titleLabel.font = font(14);
        [_btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        _btn.layer.cornerRadius = 43;
        _btn.backgroundColor = SFMNavBarColor;
    }
    return _btn;
}

#pragma mark - 巡检打卡事件
-(void)btnClick:(UIButton *)btn{
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setValue:@"appuser" forKey:@"pkPatroljl"];
    [params setValue:@"123456" forKey:@"corpname"];
    [params setValue:@"123456" forKey:@"fgsname"];
    [params setValue:@"123456" forKey:@"servicecentre"];
    [params setValue:@"123456" forKey:@"pkWorkid"];
    [params setValue:@"123456" forKey:@"workname"];
    [params setValue:@"123456" forKey:@"workphonenum"];
    [params setValue:@"123456" forKey:@"patroltime"];
    [params setValue:@"123456" forKey:@"pkPatrolarea"];
    [params setValue:@"123456" forKey:@"patrolarea"];

    [[HTTPClient shareClient] requestWithPath:@"/rest/gbInspectionSecurityController/add" AndParams:params AndReturnBlock:^(NSDictionary *dic) {
        
    } AndFailMessage:^(NSString *message, NSString *errorCode) {
        [SVProgressHUD showErrorWithStatus:message];
    }];
}

-(UILabel *)timeLabel
{
    if (_timeLabel == nil) {
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, HEIGHT - kStatusAndNavBarH -  kHomeLineH - 144 - 20, WIDTH - 30, 17)];
        _timeLabel.font = font(12);
        _timeLabel.textColor = SFM51;
        _timeLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _timeLabel;
}

-(BOOL)hidesBottomBarWhenPushed
{
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
